<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function fun1(){
				var randomColor=[];
				var color="rgb("
				for(let i=0;i<3;i++){
					randomColor[i]= Math.floor(Math.random()*256);
				
				}
				color="rgb(" + randomColor.join(",") + ")";
				console.log(color)
				document.querySelector("span").innerHTML=color;
				document.querySelector("body").setAttribute("style","background-color: "+color+";")))
			}
				
			}
			
			
		</script>
	</head>
	<body>
		<button type="button" onclick="fun1()">随机颜色</button>
		<span>rgb(255,255,255)</span>
	</body>
</html>
